package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.HotProductRequest;
import com.ytjj.qmyx.admin.service.HotProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 * 
 * @Version: 1.0
 *
 * 爆品商品管理
 */
@RestController
@RequestMapping("/hotProduct")
public class HotProductController {

    @Resource
    private HotProductService hotProductService;

    @GetMapping("/list")
    @OperLog(operModule = "爆品商品管理", operDesc = "商品列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult selectList(HotProductRequest hotProductRequest) {
        return CommonResult.success(hotProductService.selectList(hotProductRequest));
    }

    @GetMapping("/getProductChoose")
    @OperLog(operModule = "爆品商品管理", operDesc = "选择商品", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult hotProductChooseList(@RequestParam String productName) {
        return CommonResult.success(hotProductService.hotProductChooseList(productName));
    }

    @GetMapping("/insertHotProduct")
    @OperLog(operModule = "爆品商品管理", operDesc = "新增商品", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult insertHotProduct(@RequestParam Integer productId, @RequestParam String icon) {
        return CommonResult.success(hotProductService.insertHotProduct(productId, icon));
    }

    @GetMapping("/copyHotProduct")
    @OperLog(operModule = "爆品商品管理", operDesc = "复制功能", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult copyHotProduct(@RequestParam Integer id, @RequestParam Integer productId, @RequestParam String icon) {
        return CommonResult.success(hotProductService.copyHotProduct(id, productId, icon));
    }
}
